#include "GLBuffer.h"

GLBuffer::GLBuffer(GLuint name, GLenum target, GLsizeiptr size, bool immutable)
	: name(name), target(target), size(size), immutable(immutable)
{
}

GLBuffer::~GLBuffer()
{
	glDeleteBuffers(1, &name);
}

GLBuffer* GLBuffer::newMutable(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
{
	GLuint name;
	glGenBuffers(1, &name);
	GLBuffer* ret = new GLBuffer(name, target, size, false);
	glBindBuffer(target, name);
	glBufferData(target, size, data, usage);
	return ret;
}

/*GLBuffer* GLBuffer::newImmutable(GLenum target, GLsizeiptr size, const GLvoid* data, GLbitfield flags)
{
	GLuint name;
	glGenBuffers(1, &name);
	GLBuffer* ret = new GLBuffer(name, target, size, true);
	glBindBuffer(target, name);
	glBufferStorage(target, size, data, flags);
	return ret;
}*/